package xyz.yolin.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import xyz.yolin.pojo.Admin;
import xyz.yolin.service.AdminService;
import xyz.yolin.utils.MD5Utils;
import xyz.yolin.utils.MapControl;

import java.util.Map;

@Controller
public class RegisterController {
    @Autowired
    private AdminService adminService;

    @RequestMapping("/create1")
    @ResponseBody
    public Map<String,Object> create( Admin admin) {
        System.out.println(admin);
//        Admin a=new Admin(null,"admin","666666","系统操作员","sds");
        admin.setPassword(MD5Utils.getMD5(admin.getPassword()));
        int result=adminService.create(admin);
        if (result<=0){
            return MapControl.getInstance().err().getMap();
        }
        return MapControl.getInstance().success().getMap();
    }
}
